<script>
	export default {
		globalData: {
			hostUrl: '', //正式地址
			// hostUrl: 'https://resource.sxruanjian.cn', //测试地址
			statusBarHeight: 0,
			headAllHeight: 0,
			windowHeight: 0,
			windowWidth: 0,
			screenHeight: 0,
			currentVersion: '',
			safeAreaBottom: 0,
			againTaskId:''
		},
		onLaunch: function() {
			var origin = window.location.origin;
			// var origin = 'https://h5.resource.sxruanjian.cn';
			// var origin = 'https://h5.zhongchangyd.com';
			console.log('origin',origin)
			if (origin.indexOf('localhost') > 0 || origin.indexOf('sxruanjian') > 0) { //本地调取测试环境
			    // this.globalData.hostUrl = 'https://resource.sxruanjian.cn';
				this.globalData.hostUrl = 'https://resource.zhongchangyd.com';
			} else {
			   this.globalData.hostUrl = 'https://resource.zhongchangyd.com';
			}
			console.log('this.globalData.hostUrl',this.globalData.hostUrl)
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			/* 公共接口请求 */
			globalRequest(param) {
				var token;
				token = uni.getStorageSync('H5-TOKEN') ? uni.getStorageSync('H5-TOKEN') : ""
				return new Promise((resolve, reject) => {
					uni.request({
						url: `${this.globalData.hostUrl}/${param.api}`,
						method: param.method || "GET",
						timeout: 10000,
						dataType: 'json',
						header: {
							'Content-Type': 'application/json',
							'Authorization': token,
							'custom-parameter':2
						},
						data: param.data,
						success(res) {
							uni.hideLoading()
							if (res.data.code == 101) {
								uni.reLaunch({
									url:'/pages/login/login'
								})
								uni.removeStorageSync('H5-TOKEN');
							}
							resolve(res.data)
						},
						fail(err) {
							uni.hideLoading();
							uni.showToast({
								title: '网络不给力，请稍候再试！',
								icon: 'none',
								mask: true,
							})
							reject(err)
						}
					})
				})
			},
			getCustomer() {
				let that = this;
				that.globalRequest({
					api: that.getApi().user.customer,
				}).then(data => {
					if (data.code == 0) {
						window.location.href = data.data.link_url
					}
				})
			},
			getApi() {
				const apiUrl = {
					loginApi: {
						login:'api/login',
						sendSms:'api/sendSms',
						loginOut:'api/loginOut'
					},
					baseApi: {
						upload: 'api/uploadFile',
						deleteFile: 'api/deleteFile',
						protocol: 'api/protocol',
						kefu: 'api/kefu',
					},
					cash:{
						cashContributionList:'api/cashContributionList',
						cashContributionInfo:'api/cashContributionInfo',
						cashContribution:'api/cashContribution'
					},
					transfer:{
						contributionTransfer:'api/contributionTransfer',
						transferList:'api/transferList'
					},
					recharge:{
						createRechargeOrder:'api/createRechargeOrder',
						accountSetting:'api/accountSetting',
						uploadVoucher:'api/uploadVoucher',
						getRechargeList:'api/getRechargeList'
					},
					task:{
						createBuyTask:'api/createBuyTask',
						taskBuyListHall:'api/taskBuyListHall',
						receiveBuyTask:'api/receiveBuyTask',
						taskBuyList:'api/taskBuyList',
						detailBuyTask:'api/detailBuyTask'
					},
					user: {
						getUserInfo: 'api/getLoginUser',
						aliAccount:'api/aliAccount',
						customer: 'api/customer',
						userChangeRegion:'api/userChangeRegion',
						aboutUs:'api/aboutUs',
						protocolList:'api/protocolList',
						protocolDetail:'api/protocolDetail'
					},
				}
				return apiUrl
			},
		}
	}
</script>

<style lang="scss">
	@import '@/static/animate.css';
	/*每个页面公共css */
	html,
	body {
		width: 100%;
		height: 100%;
		font-size: 28rpx;
	}
	@font-face {
		font-family: 'DIN-BOLD';
		src: url(https://front.sxruanjian.cn/ttf/DIN-BOLD.TTF) format('truetype');
	}
	::-webkit-scrollbar {
		display: none;
		width: 0 !important;
		height: 0 !important;
		-webkit-appearance: none;
		
		background: transparent;
	}
	uni-button {
		position: relative;
		display: block;
		margin-left: inherit;
		margin-right: inherit;
		padding-left: 0;
		padding-right: 0;
		box-sizing: border-box;
		font-size: inherit;
		text-align: inherit;
		text-decoration: none;
		line-height: inherit;
		border-radius: inherit;
		-webkit-tap-highlight-color: inherit;
		overflow: hidden;
		color: #000;
		background-color: inherit;
		cursor: pointer;
	}
	
	uni-button:after {
		content: "";
		width: 0;
		height: 0;
		position: absolute;
		top: 0;
		left: 0;
		border: inherit;
		box-sizing: border-box;
		border-radius: inherit;
		background: transparent;
		color: #fff
	}
	uni-button[disabled]:not([type]),
	uni-button[disabled][type=default] {
		background-color: rgba(43,48,59,1.00) !important;
		color: rgba(255, 255, 255, 0.8);
		opacity: 0.6;
	}
	.line-center{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.line-v-center{
		display: flex;
		align-items: center;
	}
	.transfer-modal{
		width: 500rpx;
		height: 566rpx;
		position: fixed;
		left:0;
		right:0;
		margin:auto;
		top:362rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		.transfer-con{
			width: 500rpx;
			height: 408rpx;
			background: url(@/static/transfer-bg.png) no-repeat;
			background-size: 100% 100%;
			margin-bottom: 18rpx;
			.title{
				font-weight: bold;
				font-size: 28rpx;
				color: #1E1E1E;
				text-align: center;
				padding-top:32rpx;
			}
			.tip{
				text-align: center;
				font-size: 24rpx;
				color: #575B66;
				padding:40rpx 130rpx 0;
				line-height: 40rpx;
			}
			.transfer-btn{
				width: 420rpx;
				height: 88rpx;
				background: #1C1C1C;
				border-radius: 44rpx;
				margin:auto;
				font-size: 32rpx;
				color:#fff;
				margin-top:100rpx;
			}
		}
	}
</style>
